import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class runtest

{
	public runtest() 
	{	FileOutput FO = new FileOutput("/home/kkolakow/tmp/Fstd.log", "/home/kkolakow/tmp/Ferr.log");	
		TestingSystem Ts = new TestingSystem();
		TestingSystem.printHWreport();		}
	
	public static void PrintUsage()
	{	System.out.println("Usage java runtest -t <testname> <other test parms>");	}
	
	public static Benchmark CreateTestInstance(String[] arguments)
	{
		List<String> ArgList = new ArrayList<>();
		String ValueOfTestName = "";
		
		for ( String St : arguments )
			{	ArgList.add(St);	}
		
		int Poss_t = ArgList.indexOf("-t");
		int Poss__t = ArgList.indexOf("--testname");
		int PossOfSwitch = -9;
		
		if ( Poss__t > Poss_t )
			{	PossOfSwitch = Poss__t;	}
		else if ( Poss__t < Poss_t )
			{	PossOfSwitch	= Poss_t;	}
		else
			{			
				PrintUsage();
				System.exit(1); 
			}
		
		if ( PossOfSwitch >= 0 )
		{
			ValueOfTestName = ArgList.get(PossOfSwitch+1);

			ArgList.remove(PossOfSwitch);
			ArgList.remove(PossOfSwitch);
		}
		
		switch( ValueOfTestName )
		{
		case "linpacks":
			return new Linpacks(ArgList);
			
		case "linpackd":
			return new Linpackd(ArgList);

		case "stream":
			return new Stream(ArgList);

//		case "iozone":
//			return new iozone();

		default:
			PrintUsage();
			System.exit(1);
			return new Stream(ArgList);
			
		}
		
	}
	
	public static void main(String[] args) 
	{

	  	runtest rt = new runtest();
	  	CreateTestInstance( args );
	}
}
